← Back
Cursor Trail
[intermediate]Animated cursor trail with presets
Animated cursor trail with presets
For the full interactive experience:
$ mix raxol.playground
Code
defp move_cursor(model, dx, dy) do
{cx, cy} = model.cursor
nx = Raxol.Core.Utils.Math.clamp(cx + dx, 0, @width - 1)
ny = Raxol.Core.Utils.Math.clamp(cy + dy, 0, @height - 1)
trail = CursorTrail.update(model.trail, {nx, ny})
%{model | cursor: {nx, ny}, trail: trail}
end